package com.situ.stl.controller;

import com.situ.stl.constants.Constants;
import com.situ.stl.service.ChartsService;
import com.situ.stl.util.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/charts")
@RequiredArgsConstructor
public class ChartsController {
    @Autowired
    private ChartsService chartsService;

    /**
     * 本周课程统计
     * @param date
     * @return
     */
    @GetMapping("/weekCourse")
    public Result weekCourse(@DateTimeFormat(pattern="yyyy-MM-dd") Date date) {
        return Result.success(Constants.STATUS_200,chartsService.getCourseCount(date));
    }

    /**
     * 本周预约统计
     * @param date
     * @return
     */
    @GetMapping("/weekReserve")
    public Result weekReserve(@DateTimeFormat(pattern="yyyy-MM-dd") Date date) {
        return Result.success(Constants.STATUS_200,chartsService.getReserveCount(date));
    }

    /**
     * 本周教练带课统计
     * @param date
     * @return
     */
    @GetMapping("/weekCoach")
    public Result weekCoach(@DateTimeFormat(pattern="yyyy-MM-dd") Date date) {
        return Result.success(Constants.STATUS_200,chartsService.getCoachCount(date));
    }

    /**
     * 本周教练带课统计
     * @param date
     * @return
     */
    @GetMapping("/reserveCount")
    public Result reserveCount(@DateTimeFormat(pattern="yyyy-MM-dd") Date date) {
        return Result.success(Constants.STATUS_200,chartsService.getReserveCount(date));
    }

    /**
     * 本周教练带课统计
     * @param date
     * @return
     */
    @GetMapping("/weekMember")
    public Result weekMember(@DateTimeFormat(pattern="yyyy-MM-dd") Date date) {
        return Result.success(Constants.STATUS_200,chartsService.getMemberCount(date));
    }

    /**
     * 热门课程
     * @param date
     * @return
     */
    @GetMapping("/hotCourse")
    public Result hotCourse(@DateTimeFormat(pattern="yyyy-MM-dd") Date date) {
        return Result.success(Constants.STATUS_200,chartsService.getHotCourse(date));
    }

    /**
     * 热门教练
     * @param date
     * @return
     */
    @GetMapping("/hotCoach")
    public Result hotCoach(@DateTimeFormat(pattern="yyyy-MM-dd") Date date) {
        return Result.success(Constants.STATUS_200,chartsService.getHotCoach(date));
    }

    /**
     * 会员数量
     * @return
     */
    @GetMapping("/memberTotal")
    public Result memberTotal() {
        return Result.success(Constants.STATUS_200,chartsService.getMemberTotal());
    }

    /**
     * 教练数量
     * @return
     */
    @GetMapping("/coachTotal")
    public Result coachTotal() {
        return Result.success(Constants.STATUS_200,chartsService.getCoachTotal());
    }

    /**
     * 课程数量
     * @return
     */
    @GetMapping("/courseTotal")
    public Result courseTotal() {
        return Result.success(Constants.STATUS_200,chartsService.getCourseTotal());
    }

    /**
     * 预约数量
     * @return
     */
    @GetMapping("/reserveTotal")
    public Result reserveTotal() {
        return Result.success(Constants.STATUS_200,chartsService.getReserveTotal());
    }
}
